﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Entity.ModelConfiguration;
using CSP.Model.CSP;
using System.ComponentModel.DataAnnotations;

namespace CSP.DataAccess.Mapping
{
    public class SearchServiceListMap : EntityTypeConfiguration<SearchServiceList>
    {
        public SearchServiceListMap()
        {
            // Primary Key
            this.HasKey(t => new { t.Id });

            // Properties
            this.Property(t => t.Id)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.UserName)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.Title)
                .IsRequired()
                .HasMaxLength(100);

            this.Property(t => t.Price)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.ClassOfMemberNumber)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.PriceUnit)
                .HasMaxLength(20);

            this.Property(t => t.OriginalPriceUnit)
                .HasMaxLength(20);

            this.Property(t => t.CN_Province)
                .HasMaxLength(30);

            this.Property(t => t.CN_City)
                .HasMaxLength(30);

            this.Property(t => t.CN_County)
                .HasMaxLength(30);

            this.Property(t => t.OrderCount)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.ServiceCredit)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.RatingCount)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.FilePath)
                .HasMaxLength(200);

            this.Property(t => t.FileName)
                .HasMaxLength(50);

            // Table & Column Mappings
            this.ToTable("SearchServiceList");
            this.Property(t => t.Id).HasColumnName("Id");
            this.Property(t => t.UserName).HasColumnName("UserName");
            this.Property(t => t.Title).HasColumnName("Title");
            this.Property(t => t.Price).HasColumnName("Price");
            this.Property(t => t.OriginalPrice).HasColumnName("OriginalPrice");
            this.Property(t => t.PriceStart).HasColumnName("PriceStart");
            this.Property(t => t.PriceEnd).HasColumnName("PriceEnd");
            this.Property(t => t.PriceType).HasColumnName("PriceType");
            this.Property(t => t.ClassOfMemberNumber).HasColumnName("ClassOfMemberNumber");
            this.Property(t => t.OrderId).HasColumnName("OrderId");
            this.Property(t => t.PriceUnit).HasColumnName("PriceUnit");
            this.Property(t => t.OriginalPriceUnit).HasColumnName("OriginalPriceUnit");
            this.Property(t => t.CN_Province).HasColumnName("CN_Province");
            this.Property(t => t.CN_City).HasColumnName("CN_City");
            this.Property(t => t.CN_County).HasColumnName("CN_County");
            this.Property(t => t.OrderCount).HasColumnName("OrderCount");
            this.Property(t => t.ServiceCredit).HasColumnName("ServiceCredit");
            this.Property(t => t.RatingCount).HasColumnName("RatingCount");
            this.Property(t => t.EnterpriseAuthentication).HasColumnName("EnterpriseAuthentication");
            this.Property(t => t.PersonalAuthentication).HasColumnName("PersonalAuthentication");
            this.Property(t => t.FilePath).HasColumnName("FilePath");
            this.Property(t => t.FileName).HasColumnName("FileName");
        }
    }
}
